@<template>
  <el-container class="home-view">
    <!-- 顶部区域 -->
    <el-header height="70px">
      <img src="../assets/userlogo.jpg" alt="" />
      <div>
        <div>
          <span class="el-icon-chat-dot-round"></span>
          <span>消息</span>
        </div>
        <div class="quit" @click="quitLogin">
          <span class="el-icon-sort"></span>
          <span>交班</span>
        </div>
        <div>
          <span class="el-icon-download"></span>
          <span>下载</span>
        </div>
        <div>
          <span class="el-icon-user"></span>
          <span>{{ username }}</span>
        </div>

        <!-- <el-button type="info" @click="quitLogin">退出</el-button> -->
      </div>
    </el-header>
    <el-container>
      <!-- 侧边栏区域 -->
      <el-aside width="175px">
        <el-menu
          background-color="#1e1e1e"
          text-color="#fff"
          active-text-color="#45a0fc"
        >
          <!-- <el-submenu index="15">
            <template slot="title">
              <i class="el-icon-bank-card"></i>
              <span>消费收银</span>
            </template>
            <el-menu-item index="1-2">商品消费</el-menu-item>
          </el-submenu>
           -->
          <el-submenu :index="idx+''" v-for="(item, idx) in menuList" :key="idx">
            <!-- 一级菜单 -->
            <template slot="title"  >
              <i :class="menuIconList[idx]"></i>
              <span>{{item}}</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item :index="idx+''">商品消费</el-menu-item>
          </el-submenu>
          
        </el-menu>
      </el-aside>

      <!-- 主要显示区域 -->
      <el-main>Main</el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  created() {
    this.getMenu();
  },
  data() {
    return {
      username: "15811305718",
      
      menuList: ["消费收银", "会员管理", "商品管理", "会员营销", "报表管理", "系统设置"], //侧边栏菜单
      menuIconList: ["el-icon-bank-card", "el-icon-user", "el-icon-goods", "el-icon-present", "el-icon-tickets", "el-icon-setting"]
      
    };
  },
  methods: {
    quitLogin() {
      window.sessionStorage.clear();
      this.$router.push("/login");
    },
    async getMenu() {
      const { data: res } = await this.$http.get("menus");
      if (res.meta.status !== 200)
        return this.$message.error("菜单列表获取失败");
      // this.menuList = res.data;
    },
  },
};
</script>

<style lang="less" scoped>
.home-view {
  height: 100%;
}
.el-header {
  background-color: #2fc968;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 22px;
  > img {
    width: 175px;
    margin-left: -20px;
  }
  > div {
    width: 400px;
    // border: 1px solid;s
    height: 100%;
    margin-right: -20px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    > div {
      width: 70px;
      height: 70px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      cursor: pointer;

      > span:nth-of-type(2) {
        font-size: 14px;
      }
    }
  }
}
.el-aside {
  background-color: #1e1e1e;
  color: #fff;
}
.el-main {
  background-color: #e9edf0;
}
.el-menu-item {
  margin-left: 10px;
}
</style>>
